{include file='common/head'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>资讯管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加资讯信息','{:url(\'index/zixun/zixunadd\')}')"><i class="layui-icon"></i>添加资讯信息</button>
        <button class="layui-btn" onclick="x_admin_show('付费列表','{:url(\'index/zixun/paylist\')}')"><i class="layui-icon"></i>付费列表</button>

        <span class="x-right" style="line-height:40px">共有数据：{$sum} 条</span>
    </xblock>
    <form class="layui-form" action="">
    <table class="layui-table">
        <thead>
        <tr>
            <th>NO</th>
            <th>资讯ID</th>
            <th>标题(显示12字)</th>
            <th>配图</th>
            <th>发布时间</th>
            <th>浏览量</th>
            <th >锁定</th>
            <th >查看内容</th>
        </tr>
        </thead>
        <tbody>
        {volist name="res" id="res"}
        <tr>
            <td>{$key+1}</td>
            <td>{$res.zid}</td>
            <td >{$res['title']|mb_substr=0,12,'utf-8'}</td>
            <td><img src="{$res.picture}"></td>
            <td>{$res.createtime}</td>
            <td><?php echo count(array_filter(explode(',',$res['id'])));?></td>
            <td class="td-manage">
                <input type="checkbox" {if $res['flg'] ==1}  checked="" {/if} name="status[]" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭"/ value="{$res.zid}">
            </td>
            <td class="td-manage">
                <a title="查看资讯" href="javascript:;" attr_id='{$res.zid}' onclick="banner_edit(this)">
                    <i class="layui-icon">&#xe63c;</i><span style="color: mediumblue">查看内容</span>
                </a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    </form>
    <div class="page">
        <div>

            {$page}

        </div>
    </div>

</div>
<script>
    function banner_edit(obj){
        var mid=$(obj).attr('attr_id');
        //alert(mid);
        var url="{:Url('zixun/chakan')}?zid="+  mid;
        // alert(url);
        x_admin_show('查看资讯',url);
    }
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
        //执行一个laydate实例
        form.on('switch(switchTest)', function(data){
            var id = data.value;
            //alert(111);
            $.ajax({
                url: "{:url('index/zixun/zixundel')}",
                type: "post",
                dataType: "JSON",
                data: {zid: id},
                success: function (res) {
                    if (res ==1) {
                        layer.msg('操作成功！');
                        /*setTimeout(function () {
                            location.reload();
                        }, 1000);*/
                        return false;
                    } else {
                        layer.msg('操作失败！');
                        /*setTimeout(function () {
                            location.reload();
                        }, 1000);*/
                        return false;
                    }
                }
            });
        });
    });


</script>

</body>

</html>